APPCONF=APPCONF or assert(nil,"undefine APPCONF")
ROOTID=ROOTID or assert(nil,"undefine ROOTID")


require'zdc.doc'
require'zdc.typeex'
require'zdc.node'
require'zdc.sandbox'
require'zdc.dpl'
require'zdc.dal'
require'zdc.gim'
require'zdc.ds.module'
require'zdc.showutil'
require'zdc.clicmd'
require'zdc.logger'
require'zsvc.appbase'
require'zsvc.accept'
require'zsvc.apphandle'
require'zsvc.notifycon'
require'zsvc.notifymag'
require'zsvc.clienthandle'
require'zsvc.notifyhandle'
require'zsvc.appmag'
require'zsvc.clientmag'
require'zsvc.appcon'

LOGGER=assert(zdc.logger.defaultlog)
APPDAL=assert(zsvc.appbase.new(ZLoadConf(APPCONF)),"can't create " .. tostring(APPCONF))

myio={put=function (s,...) io.write(...) end}
ENV=zdc.clicmd.new(APPDAL.dal,ROOTID,myio,LOGGER)
function cmdloop()
	while true do
		cmd=(cmd or '') .. io.read('*l')
		if not cmd then break end
		if cmd=='!exit' then break end
		cmd=ENV:docmd(cmd,cmd:sub(#cmd)=='\t' or cmd:sub(#cmd)=='?')
		ENV:_put_prompt()
		if cmd then io.write(cmd) end
	end
end
cmdloop()
